package test.taskengine;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.liusy.jdbc.JdbcHelp;
import com.liusy.taskengine.executemodel.DBExecuteModel;
import com.liusy.taskengine.taskexecute.AbstractTaskExecute;
import com.liusy.taskengine.taskexecute.ITaskExecute;
import com.liusy.taskengine.taskmodel.ITaskModel;


/**
 * 批量执行sql的具体执行者
 * 
 * @author liusy 2012-12-11
 */
public class SqlExecuteModel extends DBExecuteModel {
	
	private static Logger log = Logger.getLogger(SqlExecuteModel.class);
	
	
	public SqlExecuteModel() {
	}

	public SqlExecuteModel(String executeModelName) {
		super(executeModelName);
	}

	@Override
	public  List<Map<String,Object>> DBTask(ITaskModel task) {
		AbstractTaskExecute _taskExecute = (AbstractTaskExecute) taskExecute;
		try {
			log.debug(_taskExecute.getName()+":.............正在执行任务.....目前连接池数:"+curActiveCount);
			List<Map<String,Object>> list=JdbcHelp.getDataObject(((SqlTaskModel)taskModel).getSql(), this.s);
			if(list.size()>0)
			log.info(list.size()+"  "+list.get(0).get("VAL"));
			log.debug(_taskExecute.getName()+":.............任务完成.....目前连接池数:"+curActiveCount);
			return list;
		} catch (Exception e) {
			log.error(e.getMessage());
			// TODO: handle exception
			return null;
		}
	}


}
